//
//  SystemConfigTableViewCell.m
//  CMVRFForIOS
//
//  Created by zhangnorman on 15/4/20.
//  Copyright (c) 2015年 hvacapp. All rights reserved.
//

#import "SystemConfigTableViewCell.h"

@interface SystemConfigTableViewCell()

@property (nonatomic,strong) UILabel *titleLabel;
@property (nonatomic,strong) UILabel *infoLabel;
@property (nonatomic,strong) UIImageView *rightImage;

@end

@implementation SystemConfigTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupViews];
    }
    return self;
}

- (void)setupViews {
    self.contentView.width = kScreen_Width;
    //标题
    self.titleLabel = [UILabel labelSingleLineFontSize:kListTitleFontSize content:@"系统2222222"];
    self.titleLabel.x = CELL_PADDING_LEFT;
    self.titleLabel.y = CELL_PADDING_TOP;
    self.titleLabel.textColor = BSBlackTextColor;
    [self.contentView addSubview:self.titleLabel];
    
    //信息label
    self.infoLabel =[UILabel labelSingleLineFontSize:kListDetailFontSize content:@"系统2222222"];
    self.infoLabel.x = CELL_PADDING_LEFT;
    self.infoLabel.numberOfLines = 2;
    self.infoLabel.y = CGRectGetMaxY(self.titleLabel.frame) + CELL_CONTENT_MARGIN;
    self.infoLabel.textColor = CM_TABLE_DETAIL_COLOR;
    [self.contentView addSubview:self.infoLabel];
    
    self.contentView.height = CGRectGetMaxY(self.infoLabel.frame) + CELL_PADDING_BOTTOM;

    //右边的导航图标
    self.rightImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"select_user_up"]];
    self.rightImage.x = kScreen_Width - CELL_PADDING_LEFT - self.rightImage.width;
    self.rightImage.centerY = self.height/2;
//    [self.contentView addSubview:self.rightImage];
    self.infoLabel.width = self.rightImage.x - self.infoLabel.x - 15;
}

- (void)setTitleStr:(NSString*)title {
    CGSize size = [Tools sizeOfSingleLineText:title withSize:kListTitleFontSize];
    self.titleLabel.size = size;
    self.titleLabel.text = title;
}

- (void)setInfoStr:(NSString*)info {
    self.infoLabel.text = info;
}

- (void)setInfoLabelHidden:(BOOL)isHiden {
    if (isHiden) {
        self.infoLabel.hidden = YES;
        self.contentView.height = CGRectGetMaxY(self.titleLabel.frame) + CELL_PADDING_BOTTOM;
    }
    else {
        self.infoLabel.hidden = NO;
        self.contentView.height = CGRectGetMaxY(self.infoLabel.frame) + CELL_PADDING_BOTTOM;

    }
}

- (void)setSubContentClosed:(BOOL)isClosed {
    if (isClosed) {
        UIImage *image = [UIImage imageNamed:@"select_user_down"];
        self.rightImage.image = image;
    }
    else {
        UIImage *image = [UIImage imageNamed:@"select_user_up"];
        self.rightImage.image = image;
    }
}

- (CGFloat)getHeight {
    return self.contentView.height;
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
